﻿namespace Cellfish.Toolbox.Linq
{
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// Provides extension methods 'hydrating' enumerables.
    /// That is making sure an source can be enumerated multiple times.
    /// </summary>
    public static class HydrateExtensions
    {
        /// <summary>
        /// Hydrates the specified enumerable.
        /// </summary>
        /// <typeparam name="T">Type of items in enumerable.</typeparam>
        /// <param name="source">The source enumerable.</param>
        /// <returns>A read only collection containing all elements in the source.</returns>
        /// <exception cref="System.ArgumentNullException">If source is null.</exception>
        public static IReadOnlyCollection<T> Hydrate<T>(this IEnumerable<T> source)
        {
            return source.ToArray();
        }
    }
}
